using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SettingPanel : BasePanel
{
    protected override void OnClick(string name)
    {
        switch (name)
        {
            case "backButton":
                UIManager.Instance.HidePanel("SettingPanel");
                UIManager.Instance.ShowPanel<MenuPanel>("MenuPanel");
                break;
        }
    }

    protected override void OnToggleChange(string toggleName, bool value)
    {
        switch (toggleName)
        {
            case "musicToggle":
                DataManager.Instance.SetMusicActive(value);
                break;
            case "soundToggle":
                DataManager.Instance.SetSoundActive(value);
                break;

            case "fullScreenToggle":
                break;
            case "windowsScreenToggle":
                break;
        }
    }

    protected override void OnSliderChange(string sliderName, float value)
    {
        switch (sliderName)
        {
            case "musicSlider":
                GetUIControl<Text>("musicNum").text=((int)(100*value)).ToString();
                DataManager.Instance.ChangeMusicValue(value);
                break;
            case "soundSlider":
                GetUIControl<Text>("soundNum").text = ((int)(100 * value)).ToString();
                DataManager.Instance.ChangeSoundValue(value);
                break;
        }
    }

    public override void ShowMe()
    {
        base.ShowMe();
        AudioData audioData = DataManager.Instance.audioData;
        GetUIControl<Toggle>("musicToggle").isOn = audioData.isOpenMusic;
        GetUIControl<Toggle>("soundToggle").isOn = audioData.isOpenSound;
        GetUIControl<Slider>("musicSlider").value = audioData.musicValue;
        GetUIControl<Slider>("soundSlider").value = audioData.soundValue;
    }
    public override void HideMe()
    {
        base.HideMe();
        DataManager.Instance.SaveAudioData();
    }
}
